<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户管理</title>
    <link rel="icon" type="image/x-icon" href="/img/favicon.jpg"/>
</head>
<!-- jquery-->
<script src="/js/jquery1.10.2.min.js"></script>
<script src="/js/index.js"></script>
<link rel="stylesheet" href="/css/pure/pure-min.css">
<link rel="stylesheet" href="/css/index.css">
<!-- Dialog -->
<link rel="stylesheet" href="https://qidian.gtimg.com/lulu/pure/css/common/ui/Dialog.css">
<script src="https://qidian.gtimg.com/lulu/pure/js/common/ui/Dialog.js"></script>
<style>
</style>
<body>

<!--导航栏-->
<div th:replace="common :: navbar"></div>
<!--中部统计数据-->
<div th:replace="common :: boxbar"></div>

<p style="margin-left: 10%;text-align: left;color: grey">
    <a href="admin/userList" class="p_button" style="color: #2a80eb" >用户管理</a>
    <a href="/modelList"  class="p_button" >模型管理</a>
<!--    <a href="/admin/newsAdd"   class="p_button" >新闻发布</a>-->
</p>

<section class="lesson_box">
    <table class="pure-table pure-table-horizontal" style="width: 100%">
        <thead>
        <tr>
            <th>序号</th>
            <th>姓名</th>
            <th>密码</th>
            <th>手机号</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="info,infoStat : ${page.list}" >
            <td th:text="${infoStat.index}"></td>
            <td th:text="${info.name}"></td>
            <td th:text="${info.passWord}"></td>
            <td th:text="${info.phone}"></td>
            <td th:text="${info.createTime}"></td>
            <td th:if="${info.status == 0}"><a href="javascript:void(0)" style="color: #2a80eb"
                                               th:onclick="active([[${info.id}]],[[${info.name}]])">启用</a></td>
            <td th:if="${info.status == 1}"><a href="javascript:void(0)" style="color: red"
                                               th:onclick="forbid([[${info.id}]],[[${info.name}]])">禁用</a></td>
<!--            <td th:if="${info.status == 1}"><a href="javascript:void(0)" style="color: #2a80eb"  th:onclick="|forbid('${info.id}')|">禁用</a></td>-->
        </tr>
        </tbody>
    </table>
</section>
<!-- 底部分页 -->
<form id="form" style="display: flex;justify-content: center" action="/admin/userList" type="POST">
    当前页  （<a  th:text="${page.currentPage+1}"  />）
    <a style="color: #2a80eb" onclick="loadPage(- 1)" th:if="${page.currentPage > 0}">上一页</a>
    <a style="color: #2a80eb"  onclick="loadPage(1)" th:if = "${page.currentPage < (page.totalPage - 1)}">下一页</a>
    共      <a style="color: #f59b00"  th:text="${page.total}" />条|
    <a style="color: #f59b00"  th:text="${page.totalPage}" />页
    每页    <a style="color: #f59b00"  th:text="${page.pageSize}" />条

    <input type="hidden" name="pageSize" th:value="${page.pageSize}" />
    <input name="currentPage" id="currentPage" type="hidden" th:value="${page.currentPage}"  />
    <input name="flag" id="flag" type="hidden" value="0"   />
</form>

<script>
    //  编辑  String  基于sendJump


    function active(userId,name) {
        var msg = confirm("是否启用用户:"+name);
        if(msg){
            sendJump("user/edit","admin/userList","id="+userId+"&status=1");
        }
    }
    function forbid(userId,name) {
        var msg = confirm("是否启用用户:"+name);
        if(msg){
            sendJump("user/edit","admin/userList","id="+userId+"&status=0");
        }
    }
    function userEdit(userId,fund) {

        alert("稍等！");
        return;

        new Dialog({
            title: '资金修改',
            content: '<h6>请填写用户资金(单位：元)</h6>' +
                '<p style="margin-top: 50px;"><input style="font-size: 18px;" id="fund" placeholder = '+fund+' type="number" class="ui-input"></p>',
            buttons: [{
                events: function (event) {
                    // 按钮禁用
                    // event.dialog是当前实例对象
                    console.log(event)
                    console.log(event.type)
                    if(event.type){
                        console.log(document.getElementById("fund").value);
                    }
                    var data = "";
                    data = data + "fund="+document.getElementById("fund").value;
                    data = data + "&id="+userId;
                    console.log(data);
                    sendJump("/user/edit","/user/list",data);
                    event.dialog.remove();
                }
            }, {}]
        });




    }
    
</script>

</body>
</html>